#pragma once

#include "plot.h"
#include "time.h"
#include "Windows.h"
#include <winuser.h>
#include <fstream>
#include <vector>

using namespace std;


clock_t tiempo1;
clock_t tiempo2;
clock_t clockInicioSin;
clock_t clockInicioStart;

cvPlotGraph* Output1;
cvPlotGraph* Output2;

vector<float> VIN;
vector<float> TIN;			// tiempo de la muestra VIN (ms)
vector<float> VOUT;
vector<float> TOUT;			// tiempo de la muestra VOUT (ms)
vector<float> VREF;
vector<float> TREF;

float Vout_ant=0;
float Vin_ant=0;
float Vin_2ant=0;

float Vin;
float Vout;
float VoutNew;


namespace ejemplo_plot {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;
	using namespace System::Runtime::InteropServices;

	/// <summary>
	/// Summary for Form1
	///
	/// WARNING: If you change the name of this class, you will need to change the
	///          'Resource File Name' property for the managed resource compiler tool
	///          associated with all .resx files this class depends on.  Otherwise,
	///          the designers will not be able to interact properly with localized
	///          resources associated with this form.
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::Button^  buttonStartPlotOutput;
	protected: 

	protected: 
	private: System::Windows::Forms::RadioButton^  radioButton1;
	private: System::Windows::Forms::RadioButton^  radioButton2;
	private: System::Windows::Forms::GroupBox^  groupBoxOutput;





	private: System::Windows::Forms::NumericUpDown^  numericUpDown2;
	private: System::Windows::Forms::NumericUpDown^  numericUpDown1;
	private: System::Windows::Forms::Label^  label3;
	private: System::Windows::Forms::Label^  label2;
	private: System::Windows::Forms::GroupBox^  groupBoxOperationMode;


	private: System::Windows::Forms::TextBox^  textBox3;
	private: System::Windows::Forms::Timer^  timer1;
	private: System::Windows::Forms::PictureBox^  pictureBox1;
	private: System::Windows::Forms::NumericUpDown^  numericUpDown3;
	private: System::Windows::Forms::Label^  label4;
	private: System::Windows::Forms::NumericUpDown^  numericUpDown4;

	private: System::Windows::Forms::Label^  label5;
	private: System::Windows::Forms::TextBox^  textBox4;
	private: System::Windows::Forms::Timer^  timer2;
	private: System::Windows::Forms::NumericUpDown^  numericUpDownConstant;

	private: System::Windows::Forms::GroupBox^  groupBoxInput;

	private: System::Windows::Forms::Label^  label6;
	private: System::Windows::Forms::NumericUpDown^  numericUpDown7;
	private: System::Windows::Forms::NumericUpDown^  numericUpDown8;
	private: System::Windows::Forms::PictureBox^  pictureBox2;
	private: System::Windows::Forms::NumericUpDown^  numericUpDown9;
	private: System::Windows::Forms::NumericUpDown^  numericUpDown10;
	private: System::Windows::Forms::Label^  label7;
	private: System::Windows::Forms::Label^  label8;








	private: System::Windows::Forms::RadioButton^  radioButtonManualMode;
	private: System::Windows::Forms::RadioButton^  radioButtonAutomaticMode;
	private: System::Windows::Forms::Label^  label1;
	private: System::Windows::Forms::ComboBox^  comboBoxOutputChannel;
	private: System::Windows::Forms::ComboBox^  comboBox1;
	private: System::Windows::Forms::Label^  label9;
	private: System::Windows::Forms::GroupBox^  groupBoxVisualAlarm;
	private: System::Windows::Forms::PictureBox^  pictureBoxAlarm;

	private: System::Windows::Forms::GroupBox^  groupBoxProcessVariables;
	private: System::Windows::Forms::Label^  labelManipulatedVariable;
	private: System::Windows::Forms::Label^  labelCurrentTime;
	private: System::Windows::Forms::Label^  labelAmplitude;
	private: System::Windows::Forms::NumericUpDown^  numericUpDownAmplitude;
	private: System::Windows::Forms::Label^  labelFrequency;
	private: System::Windows::Forms::NumericUpDown^  numericUpDownFrequency;
	private: System::Windows::Forms::GroupBox^  groupBoxController;
	private: System::Windows::Forms::NumericUpDown^  numericUpDownTD;
	private: System::Windows::Forms::Label^  label13;
	private: System::Windows::Forms::NumericUpDown^  numericUpDownKD;
	private: System::Windows::Forms::Label^  label12;
	private: System::Windows::Forms::NumericUpDown^  numericUpDownKI;
	private: System::Windows::Forms::Label^  label11;
	private: System::Windows::Forms::NumericUpDown^  numericUpDownKP;
	private: System::Windows::Forms::Label^  label10;
	private: System::Windows::Forms::GroupBox^  groupBoxFilter;
	private: System::Windows::Forms::NumericUpDown^  numericUpDownFilterB;
	private: System::Windows::Forms::Label^  label15;
	private: System::Windows::Forms::NumericUpDown^  numericUpDownFilterA;
	private: System::Windows::Forms::Label^  label14;
	private: System::Windows::Forms::Button^  buttonResetController;
	private: System::Windows::Forms::GroupBox^  groupBox1;
	private: System::Windows::Forms::Label^  label19;
	private: System::Windows::Forms::Label^  label18;
private: System::Windows::Forms::NumericUpDown^  numericUpDownSamplingTime;

	private: System::Windows::Forms::Label^  label17;
private: System::Windows::Forms::TextBox^  textBoxRWtime;

	private: System::Windows::Forms::Label^  label16;
private: System::Windows::Forms::Button^  buttonWriteSamples;
private: System::Windows::Forms::NumericUpDown^  numericUpDownNSamples;
private: System::Windows::Forms::GroupBox^  groupBoxPercentage;
private: System::Windows::Forms::Label^  label22;
private: System::Windows::Forms::ProgressBar^  progressBarY;

private: System::Windows::Forms::Label^  label21;
private: System::Windows::Forms::ProgressBar^  progressBarA;

private: System::Windows::Forms::Label^  label20;
private: System::Windows::Forms::ProgressBar^  progressBarR;
private: System::Windows::Forms::Label^  label23;
private: System::Windows::Forms::ProgressBar^  progressBarE;
private: System::Windows::Forms::PictureBox^  pictureBox3;
private: System::Windows::Forms::Label^  label26;
private: System::Windows::Forms::GroupBox^  groupBoxPlant;
private: System::Windows::Forms::NumericUpDown^  numericUpDown6;
private: System::Windows::Forms::RadioButton^  radioButtonNegativePlant;
private: System::Windows::Forms::Label^  label25;
private: System::Windows::Forms::RadioButton^  radioButtonPositivePlant;
private: System::Windows::Forms::NumericUpDown^  numericUpDownVmMax;

private: System::Windows::Forms::Label^  label24;
private: System::Windows::Forms::Label^  label27;
private: System::Windows::Forms::NumericUpDown^  numericUpDownRef;
private: System::Windows::Forms::Timer^  timer3;
private: System::Windows::Forms::TextBox^  textBox1;
private: System::Windows::Forms::Label^  label28;
private: System::Windows::Forms::Button^  button1;
private: System::Windows::Forms::NumericUpDown^  numericUpDown5;
private: System::Windows::Forms::Label^  label29;






	private: System::ComponentModel::IContainer^  components;


	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>


#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			this->components = (gcnew System::ComponentModel::Container());
			System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
			this->buttonStartPlotOutput = (gcnew System::Windows::Forms::Button());
			this->radioButton1 = (gcnew System::Windows::Forms::RadioButton());
			this->radioButton2 = (gcnew System::Windows::Forms::RadioButton());
			this->groupBoxOutput = (gcnew System::Windows::Forms::GroupBox());
			this->button1 = (gcnew System::Windows::Forms::Button());
			this->label4 = (gcnew System::Windows::Forms::Label());
			this->numericUpDown4 = (gcnew System::Windows::Forms::NumericUpDown());
			this->numericUpDown3 = (gcnew System::Windows::Forms::NumericUpDown());
			this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
			this->numericUpDown2 = (gcnew System::Windows::Forms::NumericUpDown());
			this->numericUpDown1 = (gcnew System::Windows::Forms::NumericUpDown());
			this->label3 = (gcnew System::Windows::Forms::Label());
			this->label2 = (gcnew System::Windows::Forms::Label());
			this->comboBoxOutputChannel = (gcnew System::Windows::Forms::ComboBox());
			this->label1 = (gcnew System::Windows::Forms::Label());
			this->numericUpDownConstant = (gcnew System::Windows::Forms::NumericUpDown());
			this->groupBoxOperationMode = (gcnew System::Windows::Forms::GroupBox());
			this->radioButtonManualMode = (gcnew System::Windows::Forms::RadioButton());
			this->radioButtonAutomaticMode = (gcnew System::Windows::Forms::RadioButton());
			this->textBox3 = (gcnew System::Windows::Forms::TextBox());
			this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
			this->label5 = (gcnew System::Windows::Forms::Label());
			this->textBox4 = (gcnew System::Windows::Forms::TextBox());
			this->timer2 = (gcnew System::Windows::Forms::Timer(this->components));
			this->groupBoxInput = (gcnew System::Windows::Forms::GroupBox());
			this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
			this->label9 = (gcnew System::Windows::Forms::Label());
			this->label6 = (gcnew System::Windows::Forms::Label());
			this->numericUpDown7 = (gcnew System::Windows::Forms::NumericUpDown());
			this->numericUpDown8 = (gcnew System::Windows::Forms::NumericUpDown());
			this->pictureBox2 = (gcnew System::Windows::Forms::PictureBox());
			this->numericUpDown9 = (gcnew System::Windows::Forms::NumericUpDown());
			this->numericUpDown10 = (gcnew System::Windows::Forms::NumericUpDown());
			this->label7 = (gcnew System::Windows::Forms::Label());
			this->label8 = (gcnew System::Windows::Forms::Label());
			this->groupBoxVisualAlarm = (gcnew System::Windows::Forms::GroupBox());
			this->pictureBoxAlarm = (gcnew System::Windows::Forms::PictureBox());
			this->groupBoxProcessVariables = (gcnew System::Windows::Forms::GroupBox());
			this->numericUpDown5 = (gcnew System::Windows::Forms::NumericUpDown());
			this->label29 = (gcnew System::Windows::Forms::Label());
			this->textBox1 = (gcnew System::Windows::Forms::TextBox());
			this->label28 = (gcnew System::Windows::Forms::Label());
			this->labelAmplitude = (gcnew System::Windows::Forms::Label());
			this->numericUpDownAmplitude = (gcnew System::Windows::Forms::NumericUpDown());
			this->labelFrequency = (gcnew System::Windows::Forms::Label());
			this->numericUpDownFrequency = (gcnew System::Windows::Forms::NumericUpDown());
			this->labelManipulatedVariable = (gcnew System::Windows::Forms::Label());
			this->labelCurrentTime = (gcnew System::Windows::Forms::Label());
			this->groupBoxController = (gcnew System::Windows::Forms::GroupBox());
			this->numericUpDownRef = (gcnew System::Windows::Forms::NumericUpDown());
			this->label27 = (gcnew System::Windows::Forms::Label());
			this->buttonResetController = (gcnew System::Windows::Forms::Button());
			this->numericUpDownTD = (gcnew System::Windows::Forms::NumericUpDown());
			this->label13 = (gcnew System::Windows::Forms::Label());
			this->numericUpDownKD = (gcnew System::Windows::Forms::NumericUpDown());
			this->label12 = (gcnew System::Windows::Forms::Label());
			this->numericUpDownKI = (gcnew System::Windows::Forms::NumericUpDown());
			this->label11 = (gcnew System::Windows::Forms::Label());
			this->numericUpDownKP = (gcnew System::Windows::Forms::NumericUpDown());
			this->label10 = (gcnew System::Windows::Forms::Label());
			this->groupBoxFilter = (gcnew System::Windows::Forms::GroupBox());
			this->numericUpDownFilterB = (gcnew System::Windows::Forms::NumericUpDown());
			this->label15 = (gcnew System::Windows::Forms::Label());
			this->numericUpDownFilterA = (gcnew System::Windows::Forms::NumericUpDown());
			this->label14 = (gcnew System::Windows::Forms::Label());
			this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
			this->buttonWriteSamples = (gcnew System::Windows::Forms::Button());
			this->numericUpDownNSamples = (gcnew System::Windows::Forms::NumericUpDown());
			this->label19 = (gcnew System::Windows::Forms::Label());
			this->label18 = (gcnew System::Windows::Forms::Label());
			this->numericUpDownSamplingTime = (gcnew System::Windows::Forms::NumericUpDown());
			this->label17 = (gcnew System::Windows::Forms::Label());
			this->textBoxRWtime = (gcnew System::Windows::Forms::TextBox());
			this->label16 = (gcnew System::Windows::Forms::Label());
			this->groupBoxPercentage = (gcnew System::Windows::Forms::GroupBox());
			this->label23 = (gcnew System::Windows::Forms::Label());
			this->progressBarE = (gcnew System::Windows::Forms::ProgressBar());
			this->label22 = (gcnew System::Windows::Forms::Label());
			this->progressBarY = (gcnew System::Windows::Forms::ProgressBar());
			this->label21 = (gcnew System::Windows::Forms::Label());
			this->progressBarA = (gcnew System::Windows::Forms::ProgressBar());
			this->label20 = (gcnew System::Windows::Forms::Label());
			this->progressBarR = (gcnew System::Windows::Forms::ProgressBar());
			this->pictureBox3 = (gcnew System::Windows::Forms::PictureBox());
			this->groupBoxPlant = (gcnew System::Windows::Forms::GroupBox());
			this->numericUpDown6 = (gcnew System::Windows::Forms::NumericUpDown());
			this->radioButtonNegativePlant = (gcnew System::Windows::Forms::RadioButton());
			this->label25 = (gcnew System::Windows::Forms::Label());
			this->radioButtonPositivePlant = (gcnew System::Windows::Forms::RadioButton());
			this->numericUpDownVmMax = (gcnew System::Windows::Forms::NumericUpDown());
			this->label24 = (gcnew System::Windows::Forms::Label());
			this->label26 = (gcnew System::Windows::Forms::Label());
			this->timer3 = (gcnew System::Windows::Forms::Timer(this->components));
			this->groupBoxOutput->SuspendLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown4))->BeginInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown3))->BeginInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->BeginInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown2))->BeginInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown1))->BeginInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDownConstant))->BeginInit();
			this->groupBoxOperationMode->SuspendLayout();
			this->groupBoxInput->SuspendLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown7))->BeginInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown8))->BeginInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox2))->BeginInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown9))->BeginInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown10))->BeginInit();
			this->groupBoxVisualAlarm->SuspendLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBoxAlarm))->BeginInit();
			this->groupBoxProcessVariables->SuspendLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown5))->BeginInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDownAmplitude))->BeginInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDownFrequency))->BeginInit();
			this->groupBoxController->SuspendLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDownRef))->BeginInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDownTD))->BeginInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDownKD))->BeginInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDownKI))->BeginInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDownKP))->BeginInit();
			this->groupBoxFilter->SuspendLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDownFilterB))->BeginInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDownFilterA))->BeginInit();
			this->groupBox1->SuspendLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDownNSamples))->BeginInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDownSamplingTime))->BeginInit();
			this->groupBoxPercentage->SuspendLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox3))->BeginInit();
			this->groupBoxPlant->SuspendLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown6))->BeginInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDownVmMax))->BeginInit();
			this->SuspendLayout();
			// 
			// buttonStartPlotOutput
			// 
			this->buttonStartPlotOutput->Location = System::Drawing::Point(8, 118);
			this->buttonStartPlotOutput->Name = L"buttonStartPlotOutput";
			this->buttonStartPlotOutput->Size = System::Drawing::Size(104, 31);
			this->buttonStartPlotOutput->TabIndex = 0;
			this->buttonStartPlotOutput->Text = L"Start";
			this->buttonStartPlotOutput->UseVisualStyleBackColor = true;
			this->buttonStartPlotOutput->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
			// 
			// radioButton1
			// 
			this->radioButton1->AutoSize = true;
			this->radioButton1->Location = System::Drawing::Point(23, 145);
			this->radioButton1->Name = L"radioButton1";
			this->radioButton1->Size = System::Drawing::Size(69, 17);
			this->radioButton1->TabIndex = 1;
			this->radioButton1->Text = L"Sin wave";
			this->radioButton1->UseVisualStyleBackColor = true;
			this->radioButton1->CheckedChanged += gcnew System::EventHandler(this, &Form1::radioButton1_CheckedChanged);
			// 
			// radioButton2
			// 
			this->radioButton2->AutoSize = true;
			this->radioButton2->Checked = true;
			this->radioButton2->Location = System::Drawing::Point(23, 243);
			this->radioButton2->Name = L"radioButton2";
			this->radioButton2->Size = System::Drawing::Size(67, 17);
			this->radioButton2->TabIndex = 2;
			this->radioButton2->TabStop = true;
			this->radioButton2->Text = L"Constant";
			this->radioButton2->UseVisualStyleBackColor = true;
			this->radioButton2->CheckedChanged += gcnew System::EventHandler(this, &Form1::radioButton2_CheckedChanged);
			// 
			// groupBoxOutput
			// 
			this->groupBoxOutput->Controls->Add(this->button1);
			this->groupBoxOutput->Controls->Add(this->label4);
			this->groupBoxOutput->Controls->Add(this->numericUpDown4);
			this->groupBoxOutput->Controls->Add(this->numericUpDown3);
			this->groupBoxOutput->Controls->Add(this->pictureBox1);
			this->groupBoxOutput->Controls->Add(this->numericUpDown2);
			this->groupBoxOutput->Controls->Add(this->numericUpDown1);
			this->groupBoxOutput->Controls->Add(this->label3);
			this->groupBoxOutput->Controls->Add(this->label2);
			this->groupBoxOutput->Controls->Add(this->buttonStartPlotOutput);
			this->groupBoxOutput->Location = System::Drawing::Point(267, 430);
			this->groupBoxOutput->Name = L"groupBoxOutput";
			this->groupBoxOutput->Size = System::Drawing::Size(728, 195);
			this->groupBoxOutput->TabIndex = 3;
			this->groupBoxOutput->TabStop = false;
			this->groupBoxOutput->Text = L"Output";
			// 
			// button1
			// 
			this->button1->DialogResult = System::Windows::Forms::DialogResult::Cancel;
			this->button1->Location = System::Drawing::Point(8, 158);
			this->button1->Name = L"button1";
			this->button1->Size = System::Drawing::Size(104, 31);
			this->button1->TabIndex = 13;
			this->button1->Text = L"Stop";
			this->button1->UseVisualStyleBackColor = true;
			this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click_1);
			// 
			// label4
			// 
			this->label4->AutoSize = true;
			this->label4->Location = System::Drawing::Point(5, 68);
			this->label4->Name = L"label4";
			this->label4->Size = System::Drawing::Size(62, 13);
			this->label4->TabIndex = 12;
			this->label4->Text = L"Size (pixels)";
			this->label4->Click += gcnew System::EventHandler(this, &Form1::label4_Click);
			// 
			// numericUpDown4
			// 
			this->numericUpDown4->Increment = System::Decimal(gcnew cli::array< System::Int32 >(4) {10, 0, 0, 0});
			this->numericUpDown4->Location = System::Drawing::Point(73, 92);
			this->numericUpDown4->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {1000, 0, 0, 0});
			this->numericUpDown4->Name = L"numericUpDown4";
			this->numericUpDown4->Size = System::Drawing::Size(39, 20);
			this->numericUpDown4->TabIndex = 11;
			this->numericUpDown4->UseWaitCursor = true;
			this->numericUpDown4->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) {170, 0, 0, 0});
			// 
			// numericUpDown3
			// 
			this->numericUpDown3->Increment = System::Decimal(gcnew cli::array< System::Int32 >(4) {10, 0, 0, 0});
			this->numericUpDown3->Location = System::Drawing::Point(73, 66);
			this->numericUpDown3->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {1000, 0, 0, 0});
			this->numericUpDown3->Name = L"numericUpDown3";
			this->numericUpDown3->Size = System::Drawing::Size(39, 20);
			this->numericUpDown3->TabIndex = 10;
			this->numericUpDown3->UseWaitCursor = true;
			this->numericUpDown3->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) {600, 0, 0, 0});
			// 
			// pictureBox1
			// 
			this->pictureBox1->Location = System::Drawing::Point(118, 15);
			this->pictureBox1->Name = L"pictureBox1";
			this->pictureBox1->Size = System::Drawing::Size(600, 170);
			this->pictureBox1->TabIndex = 6;
			this->pictureBox1->TabStop = false;
			this->pictureBox1->Click += gcnew System::EventHandler(this, &Form1::pictureBox1_Click);
			// 
			// numericUpDown2
			// 
			this->numericUpDown2->Location = System::Drawing::Point(73, 39);
			this->numericUpDown2->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {10, 0, 0, 0});
			this->numericUpDown2->Minimum = System::Decimal(gcnew cli::array< System::Int32 >(4) {1, 0, 0, 0});
			this->numericUpDown2->Name = L"numericUpDown2";
			this->numericUpDown2->Size = System::Drawing::Size(39, 20);
			this->numericUpDown2->TabIndex = 9;
			this->numericUpDown2->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) {1, 0, 0, 0});
			this->numericUpDown2->ValueChanged += gcnew System::EventHandler(this, &Form1::numericUpDown2_ValueChanged);
			// 
			// numericUpDown1
			// 
			this->numericUpDown1->Location = System::Drawing::Point(73, 15);
			this->numericUpDown1->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {10, 0, 0, 0});
			this->numericUpDown1->Minimum = System::Decimal(gcnew cli::array< System::Int32 >(4) {1, 0, 0, 0});
			this->numericUpDown1->Name = L"numericUpDown1";
			this->numericUpDown1->Size = System::Drawing::Size(39, 20);
			this->numericUpDown1->TabIndex = 8;
			this->numericUpDown1->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) {1, 0, 0, 0});
			this->numericUpDown1->ValueChanged += gcnew System::EventHandler(this, &Form1::numericUpDown1_ValueChanged);
			// 
			// label3
			// 
			this->label3->AutoSize = true;
			this->label3->Location = System::Drawing::Point(15, 41);
			this->label3->Name = L"label3";
			this->label3->Size = System::Drawing::Size(52, 13);
			this->label3->TabIndex = 7;
			this->label3->Text = L"Secs/Div";
			// 
			// label2
			// 
			this->label2->AutoSize = true;
			this->label2->Location = System::Drawing::Point(16, 18);
			this->label2->Name = L"label2";
			this->label2->Size = System::Drawing::Size(51, 13);
			this->label2->TabIndex = 6;
			this->label2->Text = L"Volts/Div";
			// 
			// comboBoxOutputChannel
			// 
			this->comboBoxOutputChannel->FormattingEnabled = true;
			this->comboBoxOutputChannel->Location = System::Drawing::Point(83, 112);
			this->comboBoxOutputChannel->Name = L"comboBoxOutputChannel";
			this->comboBoxOutputChannel->Size = System::Drawing::Size(54, 21);
			this->comboBoxOutputChannel->TabIndex = 17;
			// 
			// label1
			// 
			this->label1->AutoSize = true;
			this->label1->Location = System::Drawing::Point(20, 115);
			this->label1->Name = L"label1";
			this->label1->Size = System::Drawing::Size(46, 13);
			this->label1->TabIndex = 16;
			this->label1->Text = L"Channel";
			// 
			// numericUpDownConstant
			// 
			this->numericUpDownConstant->DecimalPlaces = 3;
			this->numericUpDownConstant->Increment = System::Decimal(gcnew cli::array< System::Int32 >(4) {1, 0, 0, 196608});
			this->numericUpDownConstant->Location = System::Drawing::Point(100, 240);
			this->numericUpDownConstant->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {10, 0, 0, 0});
			this->numericUpDownConstant->Minimum = System::Decimal(gcnew cli::array< System::Int32 >(4) {10, 0, 0, System::Int32::MinValue});
			this->numericUpDownConstant->Name = L"numericUpDownConstant";
			this->numericUpDownConstant->Size = System::Drawing::Size(54, 20);
			this->numericUpDownConstant->TabIndex = 13;
			// 
			// groupBoxOperationMode
			// 
			this->groupBoxOperationMode->Controls->Add(this->radioButtonManualMode);
			this->groupBoxOperationMode->Controls->Add(this->radioButtonAutomaticMode);
			this->groupBoxOperationMode->Location = System::Drawing::Point(13, 12);
			this->groupBoxOperationMode->Name = L"groupBoxOperationMode";
			this->groupBoxOperationMode->Size = System::Drawing::Size(98, 67);
			this->groupBoxOperationMode->TabIndex = 4;
			this->groupBoxOperationMode->TabStop = false;
			this->groupBoxOperationMode->Text = L"Operation Mode";
			// 
			// radioButtonManualMode
			// 
			this->radioButtonManualMode->AutoSize = true;
			this->radioButtonManualMode->Checked = true;
			this->radioButtonManualMode->Location = System::Drawing::Point(14, 42);
			this->radioButtonManualMode->Name = L"radioButtonManualMode";
			this->radioButtonManualMode->Size = System::Drawing::Size(60, 17);
			this->radioButtonManualMode->TabIndex = 1;
			this->radioButtonManualMode->TabStop = true;
			this->radioButtonManualMode->Text = L"Manual";
			this->radioButtonManualMode->UseVisualStyleBackColor = true;
			this->radioButtonManualMode->CheckedChanged += gcnew System::EventHandler(this, &Form1::radioButtonManualMode_CheckedChanged);
			// 
			// radioButtonAutomaticMode
			// 
			this->radioButtonAutomaticMode->AutoSize = true;
			this->radioButtonAutomaticMode->Location = System::Drawing::Point(14, 19);
			this->radioButtonAutomaticMode->Name = L"radioButtonAutomaticMode";
			this->radioButtonAutomaticMode->Size = System::Drawing::Size(72, 17);
			this->radioButtonAutomaticMode->TabIndex = 0;
			this->radioButtonAutomaticMode->Text = L"Automatic";
			this->radioButtonAutomaticMode->UseVisualStyleBackColor = true;
			this->radioButtonAutomaticMode->CheckedChanged += gcnew System::EventHandler(this, &Form1::radioButtonAutomaticMode_CheckedChanged);
			// 
			// textBox3
			// 
			this->textBox3->BorderStyle = System::Windows::Forms::BorderStyle::None;
			this->textBox3->Location = System::Drawing::Point(135, 19);
			this->textBox3->Name = L"textBox3";
			this->textBox3->ReadOnly = true;
			this->textBox3->Size = System::Drawing::Size(92, 13);
			this->textBox3->TabIndex = 0;
			this->textBox3->Text = L"0.000";
			// 
			// timer1
			// 
			this->timer1->Interval = 20;
			this->timer1->Tick += gcnew System::EventHandler(this, &Form1::timer1_Tick);
			// 
			// label5
			// 
			this->label5->AutoSize = true;
			this->label5->Location = System::Drawing::Point(20, 42);
			this->label5->Name = L"label5";
			this->label5->Size = System::Drawing::Size(62, 13);
			this->label5->TabIndex = 14;
			this->label5->Text = L"Read value";
			// 
			// textBox4
			// 
			this->textBox4->Location = System::Drawing::Point(83, 38);
			this->textBox4->Name = L"textBox4";
			this->textBox4->ReadOnly = true;
			this->textBox4->Size = System::Drawing::Size(144, 20);
			this->textBox4->TabIndex = 13;
			// 
			// timer2
			// 
			this->timer2->Enabled = true;
			this->timer2->Interval = 1;
			this->timer2->Tick += gcnew System::EventHandler(this, &Form1::timer2_Tick);
			// 
			// groupBoxInput
			// 
			this->groupBoxInput->Controls->Add(this->comboBox1);
			this->groupBoxInput->Controls->Add(this->label9);
			this->groupBoxInput->Controls->Add(this->label6);
			this->groupBoxInput->Controls->Add(this->numericUpDown7);
			this->groupBoxInput->Controls->Add(this->numericUpDown8);
			this->groupBoxInput->Controls->Add(this->pictureBox2);
			this->groupBoxInput->Controls->Add(this->numericUpDown9);
			this->groupBoxInput->Controls->Add(this->numericUpDown10);
			this->groupBoxInput->Controls->Add(this->label7);
			this->groupBoxInput->Controls->Add(this->label8);
			this->groupBoxInput->Location = System::Drawing::Point(267, 182);
			this->groupBoxInput->Name = L"groupBoxInput";
			this->groupBoxInput->Size = System::Drawing::Size(728, 195);
			this->groupBoxInput->TabIndex = 14;
			this->groupBoxInput->TabStop = false;
			this->groupBoxInput->Text = L"Input";
			// 
			// comboBox1
			// 
			this->comboBox1->FormattingEnabled = true;
			this->comboBox1->Location = System::Drawing::Point(74, 25);
			this->comboBox1->Name = L"comboBox1";
			this->comboBox1->Size = System::Drawing::Size(40, 21);
			this->comboBox1->TabIndex = 19;
			// 
			// label9
			// 
			this->label9->AutoSize = true;
			this->label9->Location = System::Drawing::Point(22, 28);
			this->label9->Name = L"label9";
			this->label9->Size = System::Drawing::Size(46, 13);
			this->label9->TabIndex = 18;
			this->label9->Text = L"Channel";
			// 
			// label6
			// 
			this->label6->AutoSize = true;
			this->label6->Location = System::Drawing::Point(7, 106);
			this->label6->Name = L"label6";
			this->label6->Size = System::Drawing::Size(62, 13);
			this->label6->TabIndex = 12;
			this->label6->Text = L"Size (pixels)";
			// 
			// numericUpDown7
			// 
			this->numericUpDown7->Increment = System::Decimal(gcnew cli::array< System::Int32 >(4) {10, 0, 0, 0});
			this->numericUpDown7->Location = System::Drawing::Point(74, 130);
			this->numericUpDown7->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {1000, 0, 0, 0});
			this->numericUpDown7->Name = L"numericUpDown7";
			this->numericUpDown7->Size = System::Drawing::Size(40, 20);
			this->numericUpDown7->TabIndex = 11;
			this->numericUpDown7->UseWaitCursor = true;
			this->numericUpDown7->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) {170, 0, 0, 0});
			// 
			// numericUpDown8
			// 
			this->numericUpDown8->Increment = System::Decimal(gcnew cli::array< System::Int32 >(4) {10, 0, 0, 0});
			this->numericUpDown8->Location = System::Drawing::Point(74, 104);
			this->numericUpDown8->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {1000, 0, 0, 0});
			this->numericUpDown8->Name = L"numericUpDown8";
			this->numericUpDown8->Size = System::Drawing::Size(40, 20);
			this->numericUpDown8->TabIndex = 10;
			this->numericUpDown8->UseWaitCursor = true;
			this->numericUpDown8->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) {600, 0, 0, 0});
			// 
			// pictureBox2
			// 
			this->pictureBox2->Location = System::Drawing::Point(120, 19);
			this->pictureBox2->Name = L"pictureBox2";
			this->pictureBox2->Size = System::Drawing::Size(600, 170);
			this->pictureBox2->TabIndex = 6;
			this->pictureBox2->TabStop = false;
			// 
			// numericUpDown9
			// 
			this->numericUpDown9->Location = System::Drawing::Point(74, 78);
			this->numericUpDown9->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {10, 0, 0, 0});
			this->numericUpDown9->Minimum = System::Decimal(gcnew cli::array< System::Int32 >(4) {1, 0, 0, 0});
			this->numericUpDown9->Name = L"numericUpDown9";
			this->numericUpDown9->Size = System::Drawing::Size(40, 20);
			this->numericUpDown9->TabIndex = 9;
			this->numericUpDown9->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) {1, 0, 0, 0});
			this->numericUpDown9->ValueChanged += gcnew System::EventHandler(this, &Form1::numericUpDown9_ValueChanged);
			// 
			// numericUpDown10
			// 
			this->numericUpDown10->Location = System::Drawing::Point(74, 52);
			this->numericUpDown10->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {10, 0, 0, 0});
			this->numericUpDown10->Minimum = System::Decimal(gcnew cli::array< System::Int32 >(4) {1, 0, 0, 0});
			this->numericUpDown10->Name = L"numericUpDown10";
			this->numericUpDown10->Size = System::Drawing::Size(40, 20);
			this->numericUpDown10->TabIndex = 8;
			this->numericUpDown10->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) {1, 0, 0, 0});
			this->numericUpDown10->ValueChanged += gcnew System::EventHandler(this, &Form1::numericUpDown10_ValueChanged);
			// 
			// label7
			// 
			this->label7->AutoSize = true;
			this->label7->Location = System::Drawing::Point(14, 80);
			this->label7->Name = L"label7";
			this->label7->Size = System::Drawing::Size(52, 13);
			this->label7->TabIndex = 7;
			this->label7->Text = L"Secs/Div";
			// 
			// label8
			// 
			this->label8->AutoSize = true;
			this->label8->Location = System::Drawing::Point(15, 54);
			this->label8->Name = L"label8";
			this->label8->Size = System::Drawing::Size(51, 13);
			this->label8->TabIndex = 6;
			this->label8->Text = L"Volts/Div";
			// 
			// groupBoxVisualAlarm
			// 
			this->groupBoxVisualAlarm->Controls->Add(this->pictureBoxAlarm);
			this->groupBoxVisualAlarm->Location = System::Drawing::Point(12, 85);
			this->groupBoxVisualAlarm->Name = L"groupBoxVisualAlarm";
			this->groupBoxVisualAlarm->Size = System::Drawing::Size(99, 91);
			this->groupBoxVisualAlarm->TabIndex = 15;
			this->groupBoxVisualAlarm->TabStop = false;
			this->groupBoxVisualAlarm->Text = L"Visual Alarm";
			// 
			// pictureBoxAlarm
			// 
			this->pictureBoxAlarm->Location = System::Drawing::Point(7, 15);
			this->pictureBoxAlarm->Name = L"pictureBoxAlarm";
			this->pictureBoxAlarm->Size = System::Drawing::Size(84, 70);
			this->pictureBoxAlarm->TabIndex = 0;
			this->pictureBoxAlarm->TabStop = false;
			// 
			// groupBoxProcessVariables
			// 
			this->groupBoxProcessVariables->Controls->Add(this->numericUpDown5);
			this->groupBoxProcessVariables->Controls->Add(this->label29);
			this->groupBoxProcessVariables->Controls->Add(this->textBox1);
			this->groupBoxProcessVariables->Controls->Add(this->label28);
			this->groupBoxProcessVariables->Controls->Add(this->labelAmplitude);
			this->groupBoxProcessVariables->Controls->Add(this->numericUpDownAmplitude);
			this->groupBoxProcessVariables->Controls->Add(this->labelFrequency);
			this->groupBoxProcessVariables->Controls->Add(this->numericUpDownFrequency);
			this->groupBoxProcessVariables->Controls->Add(this->labelManipulatedVariable);
			this->groupBoxProcessVariables->Controls->Add(this->textBox4);
			this->groupBoxProcessVariables->Controls->Add(this->comboBoxOutputChannel);
			this->groupBoxProcessVariables->Controls->Add(this->label5);
			this->groupBoxProcessVariables->Controls->Add(this->labelCurrentTime);
			this->groupBoxProcessVariables->Controls->Add(this->label1);
			this->groupBoxProcessVariables->Controls->Add(this->textBox3);
			this->groupBoxProcessVariables->Controls->Add(this->radioButton1);
			this->groupBoxProcessVariables->Controls->Add(this->numericUpDownConstant);
			this->groupBoxProcessVariables->Controls->Add(this->radioButton2);
			this->groupBoxProcessVariables->Location = System::Drawing::Point(13, 182);
			this->groupBoxProcessVariables->Name = L"groupBoxProcessVariables";
			this->groupBoxProcessVariables->Size = System::Drawing::Size(233, 266);
			this->groupBoxProcessVariables->TabIndex = 18;
			this->groupBoxProcessVariables->TabStop = false;
			this->groupBoxProcessVariables->Text = L"Process Variables";
			// 
			// numericUpDown5
			// 
			this->numericUpDown5->DecimalPlaces = 3;
			this->numericUpDown5->Increment = System::Decimal(gcnew cli::array< System::Int32 >(4) {1, 0, 0, 196608});
			this->numericUpDown5->Location = System::Drawing::Point(100, 210);
			this->numericUpDown5->Minimum = System::Decimal(gcnew cli::array< System::Int32 >(4) {100, 0, 0, System::Int32::MinValue});
			this->numericUpDown5->Name = L"numericUpDown5";
			this->numericUpDown5->Size = System::Drawing::Size(54, 20);
			this->numericUpDown5->TabIndex = 26;
			// 
			// label29
			// 
			this->label29->AutoSize = true;
			this->label29->Location = System::Drawing::Point(59, 212);
			this->label29->Name = L"label29";
			this->label29->Size = System::Drawing::Size(35, 13);
			this->label29->TabIndex = 25;
			this->label29->Text = L"Offset";
			// 
			// textBox1
			// 
			this->textBox1->Location = System::Drawing::Point(83, 65);
			this->textBox1->Name = L"textBox1";
			this->textBox1->ReadOnly = true;
			this->textBox1->Size = System::Drawing::Size(144, 20);
			this->textBox1->TabIndex = 24;
			this->textBox1->TextChanged += gcnew System::EventHandler(this, &Form1::textBox1_TextChanged);
			// 
			// label28
			// 
			this->label28->AutoSize = true;
			this->label28->Location = System::Drawing::Point(19, 67);
			this->label28->Name = L"label28";
			this->label28->Size = System::Drawing::Size(61, 13);
			this->label28->TabIndex = 23;
			this->label28->Text = L"Write value";
			// 
			// labelAmplitude
			// 
			this->labelAmplitude->AutoSize = true;
			this->labelAmplitude->Location = System::Drawing::Point(59, 187);
			this->labelAmplitude->Name = L"labelAmplitude";
			this->labelAmplitude->Size = System::Drawing::Size(28, 13);
			this->labelAmplitude->TabIndex = 22;
			this->labelAmplitude->Text = L"Amp";
			// 
			// numericUpDownAmplitude
			// 
			this->numericUpDownAmplitude->DecimalPlaces = 3;
			this->numericUpDownAmplitude->Increment = System::Decimal(gcnew cli::array< System::Int32 >(4) {1, 0, 0, 196608});
			this->numericUpDownAmplitude->Location = System::Drawing::Point(101, 187);
			this->numericUpDownAmplitude->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {10, 0, 0, 0});
			this->numericUpDownAmplitude->Name = L"numericUpDownAmplitude";
			this->numericUpDownAmplitude->Size = System::Drawing::Size(54, 20);
			this->numericUpDownAmplitude->TabIndex = 21;
			this->numericUpDownAmplitude->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) {1, 0, 0, 0});
			// 
			// labelFrequency
			// 
			this->labelFrequency->AutoSize = true;
			this->labelFrequency->Location = System::Drawing::Point(59, 165);
			this->labelFrequency->Name = L"labelFrequency";
			this->labelFrequency->Size = System::Drawing::Size(28, 13);
			this->labelFrequency->TabIndex = 20;
			this->labelFrequency->Text = L"Freq";
			// 
			// numericUpDownFrequency
			// 
			this->numericUpDownFrequency->Location = System::Drawing::Point(101, 165);
			this->numericUpDownFrequency->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {10000, 0, 0, 0});
			this->numericUpDownFrequency->Name = L"numericUpDownFrequency";
			this->numericUpDownFrequency->Size = System::Drawing::Size(54, 20);
			this->numericUpDownFrequency->TabIndex = 19;
			this->numericUpDownFrequency->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) {2, 0, 0, 0});
			// 
			// labelManipulatedVariable
			// 
			this->labelManipulatedVariable->AutoSize = true;
			this->labelManipulatedVariable->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, 
				System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0)));
			this->labelManipulatedVariable->Location = System::Drawing::Point(20, 90);
			this->labelManipulatedVariable->Name = L"labelManipulatedVariable";
			this->labelManipulatedVariable->Size = System::Drawing::Size(126, 13);
			this->labelManipulatedVariable->TabIndex = 18;
			this->labelManipulatedVariable->Text = L"Manipulated Variable";
			// 
			// labelCurrentTime
			// 
			this->labelCurrentTime->AutoSize = true;
			this->labelCurrentTime->Location = System::Drawing::Point(20, 19);
			this->labelCurrentTime->Name = L"labelCurrentTime";
			this->labelCurrentTime->Size = System::Drawing::Size(67, 13);
			this->labelCurrentTime->TabIndex = 1;
			this->labelCurrentTime->Text = L"Current Time";
			// 
			// groupBoxController
			// 
			this->groupBoxController->Controls->Add(this->numericUpDownRef);
			this->groupBoxController->Controls->Add(this->label27);
			this->groupBoxController->Controls->Add(this->buttonResetController);
			this->groupBoxController->Controls->Add(this->numericUpDownTD);
			this->groupBoxController->Controls->Add(this->label13);
			this->groupBoxController->Controls->Add(this->numericUpDownKD);
			this->groupBoxController->Controls->Add(this->label12);
			this->groupBoxController->Controls->Add(this->numericUpDownKI);
			this->groupBoxController->Controls->Add(this->label11);
			this->groupBoxController->Controls->Add(this->numericUpDownKP);
			this->groupBoxController->Controls->Add(this->label10);
			this->groupBoxController->Location = System::Drawing::Point(13, 466);
			this->groupBoxController->Name = L"groupBoxController";
			this->groupBoxController->Size = System::Drawing::Size(233, 157);
			this->groupBoxController->TabIndex = 19;
			this->groupBoxController->TabStop = false;
			this->groupBoxController->Text = L"Controller Properties";
			this->groupBoxController->Enter += gcnew System::EventHandler(this, &Form1::groupBoxController_Enter);
			// 
			// numericUpDownRef
			// 
			this->numericUpDownRef->DecimalPlaces = 3;
			this->numericUpDownRef->Increment = System::Decimal(gcnew cli::array< System::Int32 >(4) {1, 0, 0, 196608});
			this->numericUpDownRef->Location = System::Drawing::Point(83, 124);
			this->numericUpDownRef->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {10, 0, 0, 0});
			this->numericUpDownRef->Minimum = System::Decimal(gcnew cli::array< System::Int32 >(4) {10, 0, 0, System::Int32::MinValue});
			this->numericUpDownRef->Name = L"numericUpDownRef";
			this->numericUpDownRef->Size = System::Drawing::Size(54, 20);
			this->numericUpDownRef->TabIndex = 32;
			// 
			// label27
			// 
			this->label27->AutoSize = true;
			this->label27->Location = System::Drawing::Point(7, 124);
			this->label27->Name = L"label27";
			this->label27->Size = System::Drawing::Size(24, 13);
			this->label27->TabIndex = 31;
			this->label27->Text = L"Ref";
			// 
			// buttonResetController
			// 
			this->buttonResetController->Location = System::Drawing::Point(143, 18);
			this->buttonResetController->Name = L"buttonResetController";
			this->buttonResetController->Size = System::Drawing::Size(77, 125);
			this->buttonResetController->TabIndex = 30;
			this->buttonResetController->Text = L"Reset";
			this->buttonResetController->UseVisualStyleBackColor = true;
			this->buttonResetController->Click += gcnew System::EventHandler(this, &Form1::buttonResetController_Click);
			// 
			// numericUpDownTD
			// 
			this->numericUpDownTD->DecimalPlaces = 3;
			this->numericUpDownTD->Increment = System::Decimal(gcnew cli::array< System::Int32 >(4) {1, 0, 0, 196608});
			this->numericUpDownTD->Location = System::Drawing::Point(83, 96);
			this->numericUpDownTD->Name = L"numericUpDownTD";
			this->numericUpDownTD->Size = System::Drawing::Size(54, 20);
			this->numericUpDownTD->TabIndex = 29;
			this->numericUpDownTD->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) {4, 0, 0, 65536});
			// 
			// label13
			// 
			this->label13->AutoSize = true;
			this->label13->Location = System::Drawing::Point(7, 98);
			this->label13->Name = L"label13";
			this->label13->Size = System::Drawing::Size(20, 13);
			this->label13->TabIndex = 28;
			this->label13->Text = L"Td";
			// 
			// numericUpDownKD
			// 
			this->numericUpDownKD->DecimalPlaces = 3;
			this->numericUpDownKD->Increment = System::Decimal(gcnew cli::array< System::Int32 >(4) {1, 0, 0, 196608});
			this->numericUpDownKD->Location = System::Drawing::Point(83, 70);
			this->numericUpDownKD->Minimum = System::Decimal(gcnew cli::array< System::Int32 >(4) {100, 0, 0, System::Int32::MinValue});
			this->numericUpDownKD->Name = L"numericUpDownKD";
			this->numericUpDownKD->Size = System::Drawing::Size(54, 20);
			this->numericUpDownKD->TabIndex = 27;
			// 
			// label12
			// 
			this->label12->AutoSize = true;
			this->label12->Location = System::Drawing::Point(7, 72);
			this->label12->Name = L"label12";
			this->label12->Size = System::Drawing::Size(20, 13);
			this->label12->TabIndex = 26;
			this->label12->Text = L"Kd";
			// 
			// numericUpDownKI
			// 
			this->numericUpDownKI->DecimalPlaces = 3;
			this->numericUpDownKI->Increment = System::Decimal(gcnew cli::array< System::Int32 >(4) {1, 0, 0, 196608});
			this->numericUpDownKI->Location = System::Drawing::Point(83, 44);
			this->numericUpDownKI->Minimum = System::Decimal(gcnew cli::array< System::Int32 >(4) {100, 0, 0, System::Int32::MinValue});
			this->numericUpDownKI->Name = L"numericUpDownKI";
			this->numericUpDownKI->Size = System::Drawing::Size(54, 20);
			this->numericUpDownKI->TabIndex = 25;
			// 
			// label11
			// 
			this->label11->AutoSize = true;
			this->label11->Location = System::Drawing::Point(7, 46);
			this->label11->Name = L"label11";
			this->label11->Size = System::Drawing::Size(16, 13);
			this->label11->TabIndex = 24;
			this->label11->Text = L"Ki";
			// 
			// numericUpDownKP
			// 
			this->numericUpDownKP->DecimalPlaces = 3;
			this->numericUpDownKP->Increment = System::Decimal(gcnew cli::array< System::Int32 >(4) {1, 0, 0, 196608});
			this->numericUpDownKP->Location = System::Drawing::Point(83, 18);
			this->numericUpDownKP->Minimum = System::Decimal(gcnew cli::array< System::Int32 >(4) {100, 0, 0, System::Int32::MinValue});
			this->numericUpDownKP->Name = L"numericUpDownKP";
			this->numericUpDownKP->Size = System::Drawing::Size(54, 20);
			this->numericUpDownKP->TabIndex = 23;
			// 
			// label10
			// 
			this->label10->AutoSize = true;
			this->label10->Location = System::Drawing::Point(7, 20);
			this->label10->Name = L"label10";
			this->label10->Size = System::Drawing::Size(20, 13);
			this->label10->TabIndex = 0;
			this->label10->Text = L"Kp";
			// 
			// groupBoxFilter
			// 
			this->groupBoxFilter->Controls->Add(this->numericUpDownFilterB);
			this->groupBoxFilter->Controls->Add(this->label15);
			this->groupBoxFilter->Controls->Add(this->numericUpDownFilterA);
			this->groupBoxFilter->Controls->Add(this->label14);
			this->groupBoxFilter->Location = System::Drawing::Point(14, 629);
			this->groupBoxFilter->Name = L"groupBoxFilter";
			this->groupBoxFilter->Size = System::Drawing::Size(232, 51);
			this->groupBoxFilter->TabIndex = 20;
			this->groupBoxFilter->TabStop = false;
			this->groupBoxFilter->Text = L"Filter Properties";
			// 
			// numericUpDownFilterB
			// 
			this->numericUpDownFilterB->DecimalPlaces = 3;
			this->numericUpDownFilterB->Increment = System::Decimal(gcnew cli::array< System::Int32 >(4) {1, 0, 0, 196608});
			this->numericUpDownFilterB->Location = System::Drawing::Point(165, 21);
			this->numericUpDownFilterB->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {4096, 0, 0, 196608});
			this->numericUpDownFilterB->Name = L"numericUpDownFilterB";
			this->numericUpDownFilterB->Size = System::Drawing::Size(54, 20);
			this->numericUpDownFilterB->TabIndex = 33;
			// 
			// label15
			// 
			this->label15->AutoSize = true;
			this->label15->Location = System::Drawing::Point(139, 23);
			this->label15->Name = L"label15";
			this->label15->Size = System::Drawing::Size(14, 13);
			this->label15->TabIndex = 32;
			this->label15->Text = L"B";
			// 
			// numericUpDownFilterA
			// 
			this->numericUpDownFilterA->DecimalPlaces = 3;
			this->numericUpDownFilterA->Increment = System::Decimal(gcnew cli::array< System::Int32 >(4) {1, 0, 0, 196608});
			this->numericUpDownFilterA->Location = System::Drawing::Point(41, 21);
			this->numericUpDownFilterA->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {4096, 0, 0, 196608});
			this->numericUpDownFilterA->Name = L"numericUpDownFilterA";
			this->numericUpDownFilterA->Size = System::Drawing::Size(54, 20);
			this->numericUpDownFilterA->TabIndex = 31;
			// 
			// label14
			// 
			this->label14->AutoSize = true;
			this->label14->Location = System::Drawing::Point(15, 23);
			this->label14->Name = L"label14";
			this->label14->Size = System::Drawing::Size(14, 13);
			this->label14->TabIndex = 30;
			this->label14->Text = L"A";
			// 
			// groupBox1
			// 
			this->groupBox1->Controls->Add(this->buttonWriteSamples);
			this->groupBox1->Controls->Add(this->numericUpDownNSamples);
			this->groupBox1->Controls->Add(this->label19);
			this->groupBox1->Controls->Add(this->label18);
			this->groupBox1->Controls->Add(this->numericUpDownSamplingTime);
			this->groupBox1->Controls->Add(this->label17);
			this->groupBox1->Controls->Add(this->textBoxRWtime);
			this->groupBox1->Controls->Add(this->label16);
			this->groupBox1->Location = System::Drawing::Point(273, 631);
			this->groupBox1->Name = L"groupBox1";
			this->groupBox1->Size = System::Drawing::Size(722, 49);
			this->groupBox1->TabIndex = 21;
			this->groupBox1->TabStop = false;
			this->groupBox1->Text = L"Read - Write";
			// 
			// buttonWriteSamples
			// 
			this->buttonWriteSamples->Location = System::Drawing::Point(598, 16);
			this->buttonWriteSamples->Name = L"buttonWriteSamples";
			this->buttonWriteSamples->Size = System::Drawing::Size(110, 23);
			this->buttonWriteSamples->TabIndex = 22;
			this->buttonWriteSamples->Text = L"Write Samples";
			this->buttonWriteSamples->UseVisualStyleBackColor = true;
			this->buttonWriteSamples->Click += gcnew System::EventHandler(this, &Form1::buttonWriteSamples_Click);
			// 
			// numericUpDownNSamples
			// 
			this->numericUpDownNSamples->Location = System::Drawing::Point(540, 18);
			this->numericUpDownNSamples->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {100000, 0, 0, 0});
			this->numericUpDownNSamples->Name = L"numericUpDownNSamples";
			this->numericUpDownNSamples->Size = System::Drawing::Size(52, 20);
			this->numericUpDownNSamples->TabIndex = 21;
			this->numericUpDownNSamples->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) {200, 0, 0, 0});
			// 
			// label19
			// 
			this->label19->AutoSize = true;
			this->label19->Location = System::Drawing::Point(480, 21);
			this->label19->Name = L"label19";
			this->label19->Size = System::Drawing::Size(54, 13);
			this->label19->TabIndex = 20;
			this->label19->Text = L"# to write:";
			// 
			// label18
			// 
			this->label18->AutoSize = true;
			this->label18->Location = System::Drawing::Point(422, 23);
			this->label18->Name = L"label18";
			this->label18->Size = System::Drawing::Size(26, 13);
			this->label18->TabIndex = 19;
			this->label18->Text = L"(ms)";
			// 
			// numericUpDownSamplingTime
			// 
			this->numericUpDownSamplingTime->Location = System::Drawing::Point(348, 18);
			this->numericUpDownSamplingTime->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {67, 0, 0, 0});
			this->numericUpDownSamplingTime->Minimum = System::Decimal(gcnew cli::array< System::Int32 >(4) {4, 0, 0, 0});
			this->numericUpDownSamplingTime->Name = L"numericUpDownSamplingTime";
			this->numericUpDownSamplingTime->Size = System::Drawing::Size(68, 20);
			this->numericUpDownSamplingTime->TabIndex = 18;
			this->numericUpDownSamplingTime->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) {20, 0, 0, 0});
			// 
			// label17
			// 
			this->label17->AutoSize = true;
			this->label17->Location = System::Drawing::Point(266, 20);
			this->label17->Name = L"label17";
			this->label17->Size = System::Drawing::Size(76, 13);
			this->label17->TabIndex = 17;
			this->label17->Text = L"Sampling Time";
			// 
			// textBoxRWtime
			// 
			this->textBoxRWtime->Location = System::Drawing::Point(97, 18);
			this->textBoxRWtime->Name = L"textBoxRWtime";
			this->textBoxRWtime->ReadOnly = true;
			this->textBoxRWtime->Size = System::Drawing::Size(144, 20);
			this->textBoxRWtime->TabIndex = 15;
			// 
			// label16
			// 
			this->label16->AutoSize = true;
			this->label16->Location = System::Drawing::Point(11, 20);
			this->label16->Name = L"label16";
			this->label16->Size = System::Drawing::Size(55, 13);
			this->label16->TabIndex = 16;
			this->label16->Text = L"R-W Time";
			// 
			// groupBoxPercentage
			// 
			this->groupBoxPercentage->Controls->Add(this->label23);
			this->groupBoxPercentage->Controls->Add(this->progressBarE);
			this->groupBoxPercentage->Controls->Add(this->label22);
			this->groupBoxPercentage->Controls->Add(this->progressBarY);
			this->groupBoxPercentage->Controls->Add(this->label21);
			this->groupBoxPercentage->Controls->Add(this->progressBarA);
			this->groupBoxPercentage->Controls->Add(this->label20);
			this->groupBoxPercentage->Controls->Add(this->progressBarR);
			this->groupBoxPercentage->Location = System::Drawing::Point(598, 2);
			this->groupBoxPercentage->Name = L"groupBoxPercentage";
			this->groupBoxPercentage->Size = System::Drawing::Size(204, 181);
			this->groupBoxPercentage->TabIndex = 22;
			this->groupBoxPercentage->TabStop = false;
			this->groupBoxPercentage->Text = L"Percentage Graphs";
			// 
			// label23
			// 
			this->label23->AutoSize = true;
			this->label23->Location = System::Drawing::Point(19, 143);
			this->label23->Name = L"label23";
			this->label23->Size = System::Drawing::Size(25, 13);
			this->label23->TabIndex = 7;
			this->label23->Text = L"E(s)";
			// 
			// progressBarE
			// 
			this->progressBarE->Location = System::Drawing::Point(45, 131);
			this->progressBarE->Name = L"progressBarE";
			this->progressBarE->Size = System::Drawing::Size(150, 25);
			this->progressBarE->TabIndex = 6;
			// 
			// label22
			// 
			this->label22->AutoSize = true;
			this->label22->Location = System::Drawing::Point(18, 112);
			this->label22->Name = L"label22";
			this->label22->Size = System::Drawing::Size(25, 13);
			this->label22->TabIndex = 5;
			this->label22->Text = L"Y(s)";
			// 
			// progressBarY
			// 
			this->progressBarY->Location = System::Drawing::Point(45, 100);
			this->progressBarY->Name = L"progressBarY";
			this->progressBarY->Size = System::Drawing::Size(150, 25);
			this->progressBarY->TabIndex = 4;
			// 
			// label21
			// 
			this->label21->AutoSize = true;
			this->label21->Location = System::Drawing::Point(18, 81);
			this->label21->Name = L"label21";
			this->label21->Size = System::Drawing::Size(25, 13);
			this->label21->TabIndex = 3;
			this->label21->Text = L"A(s)";
			// 
			// progressBarA
			// 
			this->progressBarA->Location = System::Drawing::Point(45, 69);
			this->progressBarA->Name = L"progressBarA";
			this->progressBarA->Size = System::Drawing::Size(150, 25);
			this->progressBarA->TabIndex = 2;
			// 
			// label20
			// 
			this->label20->AutoSize = true;
			this->label20->Location = System::Drawing::Point(17, 50);
			this->label20->Name = L"label20";
			this->label20->Size = System::Drawing::Size(26, 13);
			this->label20->TabIndex = 1;
			this->label20->Text = L"R(s)";
			// 
			// progressBarR
			// 
			this->progressBarR->Location = System::Drawing::Point(45, 38);
			this->progressBarR->Name = L"progressBarR";
			this->progressBarR->Size = System::Drawing::Size(150, 25);
			this->progressBarR->TabIndex = 0;
			// 
			// pictureBox3
			// 
			this->pictureBox3->BackgroundImage = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"pictureBox3.BackgroundImage")));
			this->pictureBox3->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"pictureBox3.Image")));
			this->pictureBox3->InitialImage = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"pictureBox3.InitialImage")));
			this->pictureBox3->Location = System::Drawing::Point(117, 1);
			this->pictureBox3->Name = L"pictureBox3";
			this->pictureBox3->Size = System::Drawing::Size(475, 182);
			this->pictureBox3->SizeMode = System::Windows::Forms::PictureBoxSizeMode::StretchImage;
			this->pictureBox3->TabIndex = 23;
			this->pictureBox3->TabStop = false;
			// 
			// groupBoxPlant
			// 
			this->groupBoxPlant->Controls->Add(this->numericUpDown6);
			this->groupBoxPlant->Controls->Add(this->radioButtonNegativePlant);
			this->groupBoxPlant->Controls->Add(this->label25);
			this->groupBoxPlant->Controls->Add(this->radioButtonPositivePlant);
			this->groupBoxPlant->Controls->Add(this->numericUpDownVmMax);
			this->groupBoxPlant->Controls->Add(this->label24);
			this->groupBoxPlant->Controls->Add(this->label26);
			this->groupBoxPlant->Location = System::Drawing::Point(808, 2);
			this->groupBoxPlant->Name = L"groupBoxPlant";
			this->groupBoxPlant->Size = System::Drawing::Size(187, 181);
			this->groupBoxPlant->TabIndex = 24;
			this->groupBoxPlant->TabStop = false;
			this->groupBoxPlant->Text = L"Plant Properties";
			// 
			// numericUpDown6
			// 
			this->numericUpDown6->DecimalPlaces = 3;
			this->numericUpDown6->Increment = System::Decimal(gcnew cli::array< System::Int32 >(4) {1, 0, 0, 196608});
			this->numericUpDown6->Location = System::Drawing::Point(76, 143);
			this->numericUpDown6->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {0, 0, 0, 0});
			this->numericUpDown6->Minimum = System::Decimal(gcnew cli::array< System::Int32 >(4) {10, 0, 0, System::Int32::MinValue});
			this->numericUpDown6->Name = L"numericUpDown6";
			this->numericUpDown6->Size = System::Drawing::Size(54, 20);
			this->numericUpDown6->TabIndex = 37;
			this->numericUpDown6->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) {10, 0, 0, System::Int32::MinValue});
			// 
			// radioButtonNegativePlant
			// 
			this->radioButtonNegativePlant->AutoSize = true;
			this->radioButtonNegativePlant->Location = System::Drawing::Point(76, 60);
			this->radioButtonNegativePlant->Name = L"radioButtonNegativePlant";
			this->radioButtonNegativePlant->Size = System::Drawing::Size(68, 17);
			this->radioButtonNegativePlant->TabIndex = 2;
			this->radioButtonNegativePlant->TabStop = true;
			this->radioButtonNegativePlant->Text = L"Negative";
			this->radioButtonNegativePlant->UseVisualStyleBackColor = true;
			// 
			// label25
			// 
			this->label25->AutoSize = true;
			this->label25->Location = System::Drawing::Point(7, 150);
			this->label25->Name = L"label25";
			this->label25->Size = System::Drawing::Size(42, 13);
			this->label25->TabIndex = 36;
			this->label25->Text = L"Vm Min";
			// 
			// radioButtonPositivePlant
			// 
			this->radioButtonPositivePlant->AutoSize = true;
			this->radioButtonPositivePlant->Checked = true;
			this->radioButtonPositivePlant->Location = System::Drawing::Point(76, 38);
			this->radioButtonPositivePlant->Name = L"radioButtonPositivePlant";
			this->radioButtonPositivePlant->Size = System::Drawing::Size(62, 17);
			this->radioButtonPositivePlant->TabIndex = 1;
			this->radioButtonPositivePlant->TabStop = true;
			this->radioButtonPositivePlant->Text = L"Positive";
			this->radioButtonPositivePlant->UseVisualStyleBackColor = true;
			// 
			// numericUpDownVmMax
			// 
			this->numericUpDownVmMax->DecimalPlaces = 3;
			this->numericUpDownVmMax->Increment = System::Decimal(gcnew cli::array< System::Int32 >(4) {1, 0, 0, 196608});
			this->numericUpDownVmMax->Location = System::Drawing::Point(76, 117);
			this->numericUpDownVmMax->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {10, 0, 0, 0});
			this->numericUpDownVmMax->Name = L"numericUpDownVmMax";
			this->numericUpDownVmMax->Size = System::Drawing::Size(54, 20);
			this->numericUpDownVmMax->TabIndex = 35;
			this->numericUpDownVmMax->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) {10, 0, 0, 0});
			// 
			// label24
			// 
			this->label24->AutoSize = true;
			this->label24->Location = System::Drawing::Point(7, 38);
			this->label24->Name = L"label24";
			this->label24->Size = System::Drawing::Size(28, 13);
			this->label24->TabIndex = 0;
			this->label24->Text = L"Sign";
			// 
			// label26
			// 
			this->label26->AutoSize = true;
			this->label26->Location = System::Drawing::Point(7, 119);
			this->label26->Name = L"label26";
			this->label26->Size = System::Drawing::Size(45, 13);
			this->label26->TabIndex = 34;
			this->label26->Text = L"Vm Max";
			// 
			// timer3
			// 
			this->timer3->Enabled = true;
			this->timer3->Interval = 1;
			this->timer3->Tick += gcnew System::EventHandler(this, &Form1::timer3_Tick);
			// 
			// Form1
			// 
			this->AcceptButton = this->buttonStartPlotOutput;
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->AutoSize = true;
			this->CancelButton = this->button1;
			this->ClientSize = System::Drawing::Size(1001, 684);
			this->Controls->Add(this->groupBoxPlant);
			this->Controls->Add(this->pictureBox3);
			this->Controls->Add(this->groupBoxPercentage);
			this->Controls->Add(this->groupBox1);
			this->Controls->Add(this->groupBoxFilter);
			this->Controls->Add(this->groupBoxController);
			this->Controls->Add(this->groupBoxProcessVariables);
			this->Controls->Add(this->groupBoxVisualAlarm);
			this->Controls->Add(this->groupBoxInput);
			this->Controls->Add(this->groupBoxOperationMode);
			this->Controls->Add(this->groupBoxOutput);
			this->Name = L"Form1";
			this->Text = L"ControlSoftware";
			this->TransparencyKey = System::Drawing::Color::Magenta;
			this->groupBoxOutput->ResumeLayout(false);
			this->groupBoxOutput->PerformLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown4))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown3))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown2))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown1))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDownConstant))->EndInit();
			this->groupBoxOperationMode->ResumeLayout(false);
			this->groupBoxOperationMode->PerformLayout();
			this->groupBoxInput->ResumeLayout(false);
			this->groupBoxInput->PerformLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown7))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown8))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox2))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown9))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown10))->EndInit();
			this->groupBoxVisualAlarm->ResumeLayout(false);
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBoxAlarm))->EndInit();
			this->groupBoxProcessVariables->ResumeLayout(false);
			this->groupBoxProcessVariables->PerformLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown5))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDownAmplitude))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDownFrequency))->EndInit();
			this->groupBoxController->ResumeLayout(false);
			this->groupBoxController->PerformLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDownRef))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDownTD))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDownKD))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDownKI))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDownKP))->EndInit();
			this->groupBoxFilter->ResumeLayout(false);
			this->groupBoxFilter->PerformLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDownFilterB))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDownFilterA))->EndInit();
			this->groupBox1->ResumeLayout(false);
			this->groupBox1->PerformLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDownNSamples))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDownSamplingTime))->EndInit();
			this->groupBoxPercentage->ResumeLayout(false);
			this->groupBoxPercentage->PerformLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox3))->EndInit();
			this->groupBoxPlant->ResumeLayout(false);
			this->groupBoxPlant->PerformLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown6))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDownVmMax))->EndInit();
			this->ResumeLayout(false);

		}
#pragma endregion
	private: System::Void radioButton1_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
				numericUpDownConstant->Enabled=false;
				numericUpDownAmplitude->Enabled=true;
				numericUpDownFrequency->Enabled=true;
				clockInicioSin=clock();
			 }
	private: System::Void radioButton2_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
				 numericUpDownConstant->Enabled=true;
				 numericUpDownAmplitude->Enabled=false;
				 numericUpDownFrequency->Enabled=false;
			 }
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
			 //String^ name = textBox2->Text;
			 
			 String^ name = "Output Plot 1";
			 numericUpDown3->Enabled=false;
			 numericUpDown4->Enabled=false;
			 int size_x = (int)numericUpDown3->Value;
			 int size_y = (int)numericUpDown4->Value;

			 System::Drawing::Size size_pb1 = pictureBox1->Size::get();
			 pictureBox1->Size::set(System::Drawing::Size(size_x,size_y));

			 int delta_x = size_x-size_pb1.Width;
			 int delta_y = size_y-size_pb1.Height;
			 if (delta_y<0) delta_y=0;

			 System::Drawing::Size size_gb1 = groupBoxOutput->Size::get();

			 groupBoxOutput->Size::set(System::Drawing::Size(size_gb1.Width+delta_x,size_gb1.Height+delta_y));

			 Output1 = new cvPlotGraph(name,cvSize(size_x,size_y),(int)numericUpDown1->Value,(int)numericUpDown2->Value);

			 Output1->Clear();
			 timer1->Enabled=true;


			 // Settings for Input Plot
			 Output2 = new cvPlotGraph(name,cvSize(size_x,size_y),(int)numericUpDown9->Value,(int)numericUpDown10->Value);
			 Output2->Clear();

			 buttonStartPlotOutput->Enabled = false;
			 clockInicioStart=clock();
					 
		 }
private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) {

			double time = Output1->time;
			Output1->Update();

			Output2->Update();

			//en la siguiente instruccion se grafica un tramo de curva mediante rectas
			
			int i=0;
			while(TIN.at(TIN.size()-1)-TIN.at((int)TIN.size()-2-i)<=10*(int)numericUpDown9->Value*1000 && i<TIN.size()-2){
				Output2->DrawLine((double)TIN.at((int)TIN.size()-1-i)/1000,(double)VIN.at((int)TIN.size()-1-i),(double)TIN.at((int)TIN.size()-2-i)/1000,(double)VIN.at((int)TIN.size()-2-i),RED);
				i++;
			}
			
			i=0;
			if(radioButtonAutomaticMode->Checked==true && TREF.size()>=2){
			while(TREF.at(TREF.size()-1)-TREF.at((int)TREF.size()-2-i)<=10*(int)numericUpDown9->Value*1000 && i<TREF.size()-2){
				Output2->DrawLine((double)TREF.at((int)TREF.size()-1-i)/1000,(double)VREF.at((int)TREF.size()-1-i),(double)TREF.at((int)TREF.size()-2-i)/1000,(double)VREF.at((int)TREF.size()-2-i),GREEN);
				i++;
			}
			}
			i=0;
			while(TOUT.at(TOUT.size()-1)-TOUT.at((int)TOUT.size()-2-i)<=10*(int)numericUpDown2->Value*1000 && i<TOUT.size()-2){
				Output1->DrawLine((double)TOUT.at((int)TOUT.size()-1-i)/1000,(double)VOUT.at((int)TOUT.size()-1-i),(double)TOUT.at((int)TOUT.size()-2-i)/1000,(double)VOUT.at((int)TOUT.size()-2-i),BLUE);
				i++;
			}

			textBox3->Text=Output1->time.ToString();
			pictureBox1->Image = gcnew System :: Drawing :: Bitmap( Output1->Img->width,Output1->Img->height,Output1->Img->widthStep,System :: Drawing :: Imaging :: PixelFormat :: Format24bppRgb , ( System::IntPtr ) Output1->Img-> imageData);
			pictureBox2->Image = gcnew System :: Drawing :: Bitmap( Output2->Img->width,Output2->Img->height,Output2->Img->widthStep,System :: Drawing :: Imaging :: PixelFormat :: Format24bppRgb , ( System::IntPtr ) Output2->Img-> imageData);

		 }

private: System::Void numericUpDown1_ValueChanged(System::Object^  sender, System::EventArgs^  e) {
			Output1->volts_per_div=(int)numericUpDown1->Value;
		 }
private: System::Void numericUpDown2_ValueChanged(System::Object^  sender, System::EventArgs^  e) {
			Output1->segs_per_div=(int)numericUpDown2->Value;
		 }
private: System::Void pictureBox1_Click(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void label4_Click(System::Object^  sender, System::EventArgs^  e) {
		 }
		 // Proceso de Lectura
private: System::Void timer2_Tick(System::Object^  sender, System::EventArgs^  e) {
			tiempo1=clock();
			lee(&Vin);
			VIN.push_back(Vin);
			TIN.push_back((float)(clock()-clockInicioStart));
			if(radioButtonAutomaticMode->Checked==true){
				TREF.push_back((float)(clock()-clockInicioStart));
				VREF.push_back((float)(numericUpDownRef->Value));
			}
			
			if (radioButtonAutomaticMode->Checked==true){
		// guardamos los parametros a usar, de modo que no puedan ser cambiados durante el calculo
				float Kp=(float)numericUpDownKP->Value;
				float Ki=(float)numericUpDownKI->Value;
				float Kd=(float)numericUpDownKD->Value;
				float Tmc=(float)numericUpDownTD->Value;
				float Ref=(float)numericUpDownRef->Value;

				float k1=Kp+Ki*Tmc/2+Kd/Tmc;
				float k2=-Kp+Ki*Tmc/2-2*Kd/Tmc;
				float k3=Kd/Tmc;

				Vout=Vout_ant+k1*(Ref-Vin)+k2*(Ref-Vin_ant)+k3*(Ref-Vin_2ant);

				
			}
			else{
				if (radioButton2->Checked==true)
					Vout=(float)numericUpDownConstant->Value;
				
				else{
					Vout=(float)numericUpDownAmplitude->Value*sin(2*Math::PI*(float)numericUpDownFrequency->Value*(clock()-clockInicioSin)/1000)+(float)numericUpDown5->Value;
				} 
			}

			Vin_2ant=Vin_ant;
			Vin_ant=Vin;
			Vout_ant=Vout;

			VOUT.push_back(Vout);
			TOUT.push_back((float)(clock()-clockInicioStart));

			textBox4->Text=Vin.ToString();
			textBox1->Text=Vout.ToString();

			tiempo2=clock();
			
			
		 }
private: System::Void buttonStartPlotInput_Click(System::Object^  sender, System::EventArgs^  e) {
			 String^ name = "Input Plot 1";
			 numericUpDown7->Enabled=false;
			 numericUpDown8->Enabled=false;
			 int size_x = (int)numericUpDown7->Value;
			 int size_y = (int)numericUpDown8->Value;

			 System::Drawing::Size size_pb2 = pictureBox2->Size::get();
			 pictureBox2->Size::set(System::Drawing::Size(size_x,size_y));

			 int delta_x = size_x-size_pb2.Width;
			 int delta_y = size_y-size_pb2.Height;
			 if (delta_y<0) delta_y=0;

			 System::Drawing::Size size_gb2 = groupBoxInput->Size::get();

			 groupBoxInput->Size::set(System::Drawing::Size(size_gb2.Width+delta_x,size_gb2.Height+delta_y));


			 timer1->Enabled=true;
		 }
private: System::Void radioButtonAutomaticMode_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {

			 numericUpDown7->Enabled=false;
			 numericUpDown8->Enabled=false;
			 
		 }
private: System::Void groupBoxController_Enter(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void radioButtonManualMode_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
				TREF.clear();
				VREF.clear();		 
		 }
private: System::Void timer3_Tick(System::Object^  sender, System::EventArgs^  e) {
			VoutNew=Vout/4.8828+2.048; 
			escribe(&VoutNew);
			

		 }
private: System::Void textBox1_TextChanged(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void numericUpDown10_ValueChanged(System::Object^  sender, System::EventArgs^  e) {
		Output2->volts_per_div=(int)numericUpDown10->Value;
		 }
private: System::Void numericUpDown9_ValueChanged(System::Object^  sender, System::EventArgs^  e) {
		Output2->segs_per_div=(int)numericUpDown9->Value;
		
		 }
private: System::Void button1_Click_1(System::Object^  sender, System::EventArgs^  e) {
			 Form1::Close();
		 }
private: System::Void buttonWriteSamples_Click(System::Object^  sender, System::EventArgs^  e) {
			 
		 SYSTEMTIME st;
		 GetSystemTime(&st);

         vector<float> auxVIN = VIN;
         vector<float> auxTIN = TIN;
         vector<float> auxVOUT = VOUT;
         vector<float> auxTOUT = TOUT;

		 char file_name [50];
		 char print_str [20];
		 sprintf (print_str, "%d-%d %d_%d_%d", st.wDay, st.wMonth, st.wHour - 4, st.wMinute, st.wSecond);
		 sprintf (file_name, "%s.csv", print_str);
         //printf( "The current time is %s \n", timeStr);
    		
		 char content [50000];

		 int nSamples = (int)numericUpDownNSamples->Value;
		 int start_i_vin = auxVIN.size() - nSamples;
		 if(start_i_vin < 0)
		 {
			 start_i_vin = 0;
			 char message [100];
			 sprintf(message, "Number of samples too high, writing only %d samples", auxVIN.size());
	         printf(message);			 
			 //MessageBox(NULL, (LPCTSTR)message, NULL, NULL);
		 }

		 sprintf(content, "T_IN, V_IN, \n");
			 for(int i = start_i_vin; i < auxVIN.size(); i++)
		 {
			 sprintf(content, "%s, %f, %f,\n", content, auxTIN.at(i), auxVIN.at(i));
		 }

		 sprintf(content, "%s, , \n", content);
		 sprintf(content, "%s, T_OUT, V_OUT, \n", content);

		 int start_i_vout = auxVOUT.size() - nSamples;
		 if(start_i_vout < 0)
		 {
			 start_i_vout = 0;
			 char message [100];
			 sprintf(message, "Number of samples too high, writing only %d samples", auxVOUT.size());
	         printf(message);
			 //MessageBox(NULL, (LPCTSTR)message, NULL, NULL);
		 }


		 for(int i = start_i_vout; i < auxVOUT.size(); i++)
		 {
			 sprintf(content, "%s, %f, %f,\n", content, auxTOUT.at(i), auxVOUT.at(i));
		 }

		 ofstream myfile;
		 myfile.open (file_name);
		 myfile << content;
		 myfile.close();
		 }
};
}

